package com.yanwq.sayhi.rest;

import com.yanwq.sayhi.bean.Reply;
import com.yanwq.sayhi.service.ReplyService;
import com.yanwq.sayhi.tool.JSONResultTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * 作者：闫伟强。
 * 日期：2016/6/14。
 */
@RestController
@RequestMapping(path = "/reply")
public class ReplyRest {

    @Autowired
    private ReplyService service;

    @RequestMapping(path = "/add")
    public String add(@RequestBody Reply reply) {
        reply.setUuid(UUID.randomUUID().toString());
        reply.setPublishTime(System.currentTimeMillis());
        service.add(reply);
        return JSONResultTool.makeJSONResult("添加成功");
    }
}
